package com.atguigu.gulimall.ware.dao;

import com.atguigu.gulimall.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * 商品库存
 * 
 * @author dy
 * @email 1091330089@qq.com
 * @date 2022-08-11 16:51:40
 */
@Mapper
@Repository
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {


    void addSkuStock(@Param("skuId") Long skuId, @Param("skuNum") Integer skuNum, @Param("wareId") Long wareId);

    /**
     * @Author dy
     * @Description: 根据skuid 查询返回库存数量
     */
    @Select("SELECT sum(stock-stock_locked) from wms_ware_sku where sku_id = #{0}")
    Long hasstockBySkuId(Long skuId);
}
